import request from "@/utils/request";
import type {PwdLoginDTO, SimulateWxLoginDTO, UserInfoDTO, UserInfoVO, WxLoginDTO} from "@/types/loginType";
import type { Response } from "@/types/response";

enum ENUM {
   wxLoginAPI = "/login/wxMin",
   simulateLoginAPI = "/login/wxMin/simple",
   passwordLoginAPI = "/login",
   fetchProfileAPI="/member/profile",
   updateProfileAPI="/member/profile"
}

/**
 * @description 用户名+密码登录的接口
 * */
export const passwordLoginAPI = (data: PwdLoginDTO): Promise<Response<UserInfoVO>> => request<UserInfoVO>({
   url: ENUM.passwordLoginAPI,
   method: "POST",
   data,
});

/**
 * @description 微信登录的接口
 * */
export const wxLoginAPI = (data: WxLoginDTO): Promise<Response<UserInfoVO>> => request<UserInfoVO>({
   url: ENUM.wxLoginAPI,
   method: "POST",
   data,
});

/**
 * @description 模拟登录的接口
 * */
export const simulateLoginAPI = (data: SimulateWxLoginDTO): Promise<Response<UserInfoVO>> => request<UserInfoVO>({
   url: ENUM.simulateLoginAPI,
   method: "POST",
   data,
});

/**
 * @description 获取用户信息的接口
 * */
export const fetchProfileAPI=():Promise<Response<UserInfoVO>> =>request<UserInfoVO>({
   url:ENUM.fetchProfileAPI,
   method: "GET",
})

/**
 * @description 修改用户信息的接口
 * */
export const updateProfileAPI=(data:UserInfoDTO)=>request<UserInfoVO>({
   url:ENUM.updateProfileAPI,
   method:"PUT",
   data
})